# -*- coding: utf-8 -*
# @author 小测试
# @create 2020-03-03 22:57
import os
from ApiDemo.util.tools.open_ini import Config

def report():
    # 定义环境
    # 定义报告中environment
    conf = Config()
    host = conf.host_test
    tester = conf.tester_test
    versionCode = conf.versionCode_test
    data_list = []
    data_list.append('{} = {}\n'.format("host", host))
    data_list.append('{} = {}\n'.format("tester", tester))
    data_list.append('{} = {}\n'.format("versionCode", versionCode))
    with open("result/xml/environment.properties", "w", encoding="utf-8")  as f:
        f.writelines(data_list)


if __name__ == '__main__':
    #执行pytest的命令
    #全部执行  pytest
    #执行冒烟用例  pytest  -m smoke
    #执行其他用例 pytest -m test
    os.system("pytest ")
    #allure收集结果 进行展示
    report()
    os.system("allure   generate ./result/xml  -o  ./result/html  --clean")
